package com.red.star.wechat.data.mappers;

import com.red.star.wechat.data.core.base.MyMapper;
import com.red.star.wechat.data.entity.ClientLife;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author nofish.yan@gmail.com
 * @date 2018/3/19.
 */
public interface ClientHideMapper extends MyMapper<ClientLife> {

    List<ClientLife> findClientAndMobileBySmsLog(@Param("cActiveTime") Integer cActiveTime, @Param("bActiveTime") Integer bActiveTime);

    List<ClientLife> findClientAndMobileBySmsLogNew(@Param("cActiveTime") Integer cActiveTime, @Param("bActiveTime") Integer bActiveTime);

    @Update("UPDATE t_client_life SET hide_time = now()  WHERE fans_id = #{fansId}")
    void updateHideTime(Integer fansId);

    @Update("UPDATE t_client_life SET last_login_time = now()  WHERE fans_id = #{fansId}")
    void updateLastLoginTime(Integer fansId);

    @Insert("INSERT INTO t_client_life(`fans_id`, `hide_time`) VALUES (#{fansId}, now())")
    void insertHideTime(Integer fansId);

    @Insert("INSERT INTO t_client_life(`fans_id`, `last_login_time`) VALUES (#{fansId}, now())")
    void insertLastLoginTime(Integer fansId);

    @Select("SELECT * FROM t_client_life WHERE fans_id = #{fansId}")
    ClientLife findOneByFansId(Integer fansId);
}
